<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">

<h:body>

	<ui:composition template="/WEB-INF/Facelets/template.xhtml">

		<ui:define name="content">

			<div id="content-lista-locacao">
				<h:form>
					<p:growl id="growl" showDetail="true" />
					<p:fieldset legend="Lista de Locação" toggleable="true"
						toggleSpeed="500">
						<p:ajax event="toggle" update="growl" />
						<h:panelGrid columns="2" cellpadding="10">

							<p:dataTable id="dataTable" var="l"
								value="#{LocacaoMB.LoadAll()}" rows="5" selectionMode="single"
								rowKey="#{l.id}" paginator="true"
								selection="#{LocacaoMB.selectLocacao}" sortMode="multiple">

								<p:column sortBy="Código" headerText="Código">
									<h:outputText value="#{l.id}" />
								</p:column>

								<p:column sortBy="Nome do Cliente" headerText="Cliente">
									<h:outputText value="#{l.id_cliente}" />
								</p:column>

								<p:column sortBy="Nome do Veiculo" headerText="Nome do Veiculo">
									<h:outputText value="#{l.id_automovel}" />
								</p:column>

								<p:column sortBy="Marca" headerText="Marca">
									<h:outputText value="#{l.nome}" />
								</p:column>

								<p:column sortBy="Modelo" headerText="Modelo">
									<h:outputText value="#{l.modelo}" />
								</p:column>

								<p:column sortBy="Data Cadastro" headerText="Data Cadastro">
									<h:outputText value="#{l.dt_locacao}" />
								</p:column>

							</p:dataTable>

						</h:panelGrid>
					</p:fieldset>
					<p:panelGrid columns="4">
						<p:commandButton value="Inserir"
							action="#{LocacaoMB.redirect(true)}" />
						<p:commandButton value="Alterar"
							action="#{LocacaoMB.redirect(false)}" />
						<p:commandButton value="deletar" action="#{LocacaoMB.delete}"
							update="dataTable" oncomplete="dialog.show()" />
						<p:commandButton value="Voltar" action="#" />
					</p:panelGrid>
					<p:dialog widgetVar="dialog" modal="true">
						<h:panelGrid id="display" columns="2" cellpadding="5">

							<h:outputText value="Operação realizada com sucesso!" />

						</h:panelGrid>
					</p:dialog>

				</h:form>


			</div>


		</ui:define>

	</ui:composition>

</h:body>
</html>